home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
usr (gcc 1.37 libs)
/
mac
/
lseek.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-08
|
808b
|
33 lines
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include "crtlocal.h"
off_t lseek(int fd, off_t off, int nMode)
{
ParamBlockRec pbr;
if (crt_fd_tab[fd].flags & O_PIPE)
{
return 0;
}
if (nMode == SEEK_SET)
nMode = fsFromStart;
else if (nMode == SEEK_CUR)
nMode = fsFromMark;
else if (nMode == SEEK_END)
nMode = fsFromLEOF;
pbr.ioParam.ioRefNum = crt_fd_tab[fd].fd;
pbr.ioParam.ioPosMode = nMode;
pbr.ioParam.ioPosOffset = off;
PBSetFPosSync(&pbr);
if ((eofErr == pbr.ioParam.ioResult) && (nMode == fsFromStart))
{
pbr.ioParam.ioMisc = (Ptr)off;
PBSetEOFSync(&pbr);
pbr.ioParam.ioPosMode = nMode;
pbr.ioParam.ioPosOffset = off;
PBSetFPosSync(&pbr);
}
return pbr.ioParam.ioPosOffset;
}